package com.ict.web.controller.yzq;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.enums.BusinessType;
import com.ict.common.utils.StringUtils;
import com.ict.web.constant.Constants;
import com.ict.web.constant.ProjectStatusEnum;
import com.ict.web.controller.file.domain.YzqFile;
import com.ict.web.controller.file.service.IYzqFileService;
import com.ict.web.domain.*;
import com.ict.web.dto.ProjectManagementAddDto;
import com.ict.web.dto.ProjectManagementDto;
import com.ict.web.dto.ProjectManagementEditDto;
import com.ict.web.dto.ProjectManagementListDto;
import com.ict.web.mapper.ApprovalMapper;
import com.ict.web.service.*;
import com.ict.web.service.impl.ScoreServiceImpl;
import com.ict.web.utils.pdf.RoleUtil;
import com.ict.web.vo.*;
import io.jsonwebtoken.lang.Collections;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 项目管理Controller
 *
 * @author ruoyi
 * @date 2022-02-14
 */
@Api(tags = "项目管理")
@RestController
@RequestMapping("/management")
public class ProjectManagementController extends BaseController
{
    @Autowired
    private IProjectManagementService projectManagementService;

    @Autowired
    private IComplianceService complianceService;

    @Autowired
    private ILastCheckService lastCheckService;

    @Autowired
    private ScoreServiceImpl scoreService;


    @Autowired
    private IAnnualDeclarationService annualDeclarationService;

    @Autowired
    private ISupplementaryDeclarationService supplementaryDeclarationService;

    @Autowired
    private ISchemeDeclarationService schemeDeclarationService;

    @Autowired
    private IFinanceService financeService;

    @Autowired
    private IPreliminaryInformationService preliminaryInformationService;

    @Autowired
    private IContractInformationService contractInformationService;

    @Autowired
    private IMilestoneInformationService milestoneInformationService;
    @Autowired
    private IYzqFileService fileService;
    @Autowired
    private IApprovalService approvalService;
    @Autowired
    private ApprovalMapper approvalMapper;
    @Autowired
    private IAnnualProjectPlanService annualProjectPlanService;
    @Resource
    private IGovernmentDataResourcesService governmentDataResourcesService;

    @Resource
    private ICloudResourceRequirementService cloudResourceRequirementService;

    @Resource
    private IIotDeviceInfoService iotDeviceInfoService;

    @Resource
    private ISystemInfoService systemInfoService;
    @Resource
    private ProjectSystemInfoService projectSystemInfoService;
    /**
     * 查询项目管理列表
     */
    @PreAuthorize("@ss.hasPermi('web:management:list')")
    @ApiOperation("查询项目管理列表")
    @GetMapping("/list")
    public AjaxResult list(ProjectManagementDto dto)
    {
        ProjectManagementListDto listDto = new ProjectManagementListDto();
        BeanUtils.copyProperties(dto,listDto);
        List<ProjectManagementListVo> listVos = projectManagementService.selectProjectManagementList(listDto);
        return AjaxResult.success()
                .put("pageSize",dto.getPageSize())
                .put("pageNum",dto.getPageNum())
                .put("total",listVos.size())
                .put("setPages",(int)Math.ceil((double)listVos.size()/dto.getPageSize()))
                .put("list",listVos.size()!=0?projectManagementService.selectProjectList(dto):"");
    }

    /**
     * 查询我的项目管理列表
     *
     * @param dto 项目管理
     * @return 项目管理
     */
    @ApiOperation("查询我的项目管理列表")
    @GetMapping("/my/list")
    public PageInfo<ProjectManagementListVo> selectMyProject(ProjectManagementListDto dto){
        return projectManagementService.selectMyProject(dto);
    }

    /**
     * 获取项目管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('web:management:query')")
    @ApiOperation("获取项目管理详细信息")
    @GetMapping(value = "/{proId}")
    public AjaxResult getInfo(@PathVariable("proId") Long proId)
    {
        AjaxResult ajax = AjaxResult.success();
        ProjectManagement bean = projectManagementService.getById(proId);
        ProjectManagementVo projectManagementVo = new ProjectManagementVo();
        BeanUtils.copyProperties(bean,projectManagementVo);
        //合规
        Compliance compliance = complianceService.getById(bean.getComplianceId());
        if(StringUtils.isNotNull(compliance)){
            ComplianceDetalisVo complianceDetalisVo = new ComplianceDetalisVo();
            BeanUtils.copyProperties(compliance,complianceDetalisVo);
            if(StringUtils.isNotNull(compliance.getTryEffectDescriptionStuff())){
                YzqFile filePD = fileService.getById(compliance.getTryEffectDescriptionStuff());
                complianceDetalisVo.setTryEffectDescriptionStuffFile(filePD);
            }
            ajax.put("Compliance",complianceDetalisVo);
        }
        //绩效评价
        ajax.put("Score",scoreService.selectScoreList(proId));
        //年度申报
        AnnualDeclaration annualDeclaration = annualDeclarationService.getById(bean.getAnnualId());
        if(StringUtils.isNotNull(annualDeclaration)){
            YzqFile filePP = fileService.getById(annualDeclaration.getProjectProposal());
            AnnualDeclarationVo annualDeclarationVo = new AnnualDeclarationVo();
            BeanUtils.copyProperties(annualDeclaration,annualDeclarationVo);
            AnnualProjectPlan annualProjectPlan = annualProjectPlanService.getById(annualDeclarationVo.getPlanId());
            Assert.isTrue(StringUtils.isNotNull(annualProjectPlan),"未找到该项目的年度计划");
            annualDeclarationVo.setPlanName(annualProjectPlan.getName());
            annualDeclarationVo.setProjectProposalFile(filePP);
            ajax.put("AnnualDeclaration",annualDeclarationVo);
        }

        //增补申报
        SupplementaryDeclaration supplementaryDeclaration = supplementaryDeclarationService.getById(bean.getSupplementaryId());
        if(StringUtils.isNotNull(supplementaryDeclaration)){
            YzqFile fileSV = fileService.getById(supplementaryDeclaration.getSupplementaryVoucher());
            SupplementaryDeclarationVo supplementaryDeclarationVo = new SupplementaryDeclarationVo();
            BeanUtils.copyProperties(supplementaryDeclaration,supplementaryDeclarationVo);
            supplementaryDeclarationVo.setSupplementaryVoucherFile(fileSV);
            YzqFile filePp = fileService.getById(supplementaryDeclaration.getProjectProposal());
            supplementaryDeclarationVo.setProjectProposalFile(filePp);
            ajax.put("SupplementaryDeclaration",supplementaryDeclarationVo);
        }

        //方案申报
        SchemeDeclaration schemeDeclaration = schemeDeclarationService.getById(bean.getProgrammeId());
        if(StringUtils.isNotNull(schemeDeclaration)){
            SchemeDeclarationVo schemeDeclarationVo = new SchemeDeclarationVo();
            BeanUtils.copyProperties(schemeDeclaration,schemeDeclarationVo);
            if(StringUtils.isNotNull(schemeDeclaration.getResearchReport())){
                YzqFile fileRR = fileService.getById(schemeDeclaration.getResearchReport());
                schemeDeclarationVo.setResearchReportFile(fileRR);
            }
            if(StringUtils.isNotNull(schemeDeclaration.getBudgetProposal())){
                YzqFile fileBP = fileService.getById(schemeDeclaration.getBudgetProposal());
                schemeDeclarationVo.setBudgetProposalFile(fileBP);
            }
            if(StringUtils.isNotNull(schemeDeclaration.getBudgetProgramme())){
                YzqFile fileBPm = fileService.getById(schemeDeclaration.getBudgetProgramme());
                schemeDeclarationVo.setBudgetProgrammeFile(fileBPm);
            }
            if(StringUtils.isNotNull(schemeDeclaration.getPreliminaryDesignScheme())){
                YzqFile filePD = fileService.getById(schemeDeclaration.getPreliminaryDesignScheme());
                schemeDeclarationVo.setPreliminaryDesignSchemeFile(filePD);
            }
            if(StringUtils.isNotNull(schemeDeclaration.getCloudResourceApplication())){
                YzqFile fileCA = fileService.getById(schemeDeclaration.getCloudResourceApplication());
                schemeDeclarationVo.setCloudResourceApplicationFile(fileCA);
            }
            //系统信息
            List<SystemInfo> systemInfoList = systemInfoService.lambdaQuery().eq(SystemInfo::getProgrammeId, schemeDeclaration.getProgrammeId()).list();
            //系统是否上云
            List<SystemInfoDetailVo> arrayList = new ArrayList<>();
            systemInfoList.stream().forEach(s->{
                SystemInfoDetailVo systemInfoDetailVo = new SystemInfoDetailVo();
                BeanUtils.copyProperties(s,systemInfoDetailVo);
                List<ProjectSystemInfo> list = projectSystemInfoService.lambdaQuery().eq(ProjectSystemInfo::getAppName, s.getSystemName()).list();
                if(StringUtils.isNotEmpty(list)){
                    if(list.get(0).getAppIsCloud()){
                        systemInfoDetailVo.setAppIsCloud("1");
                    }else {
                        systemInfoDetailVo.setAppIsCloud("0");
                    }

                }else {
                    systemInfoDetailVo.setAppIsCloud("0");
                }
                arrayList.add(systemInfoDetailVo);
            });
            schemeDeclarationVo.setSystemInfoList(arrayList);
            //政务数据资源目录清单
            List<GovernmentDataResources> governmentDataResourcesList = governmentDataResourcesService.lambdaQuery()
                    .eq(GovernmentDataResources::getProgrammeId, schemeDeclaration.getProgrammeId()).list();
            schemeDeclarationVo.setGovernmentDataResourcesAddDtoList(governmentDataResourcesList);
            //云资源需求
            List<CloudResourceRequirement> cloudResourceRequirementList = cloudResourceRequirementService.lambdaQuery()
                    .eq(CloudResourceRequirement::getProgrammeId, schemeDeclaration.getProgrammeId()).list();
            schemeDeclarationVo.setInsertCloudResourceDtoList(cloudResourceRequirementList);
            //物联设备信息
            List<IotDeviceInfo> iotDeviceInfoList = iotDeviceInfoService.lambdaQuery()
                    .eq(IotDeviceInfo::getProgrammeId, schemeDeclaration.getProgrammeId()).list();
            schemeDeclarationVo.setInsertIotDeviceInfoDtosList(iotDeviceInfoList);
            ajax.put("SchemeDeclaration",schemeDeclarationVo);
        }

        //发改/财政局审批结果备案
        Finance finance = financeService.getById(bean.getFinanceId());
        if(StringUtils.isNotNull(finance)){
            FinanceVo financeVo = new FinanceVo();
            BeanUtils.copyProperties(finance,financeVo);
            if(StringUtils.isNotNull(finance.getApprovalAnnexId())){
                YzqFile filePD = fileService.getById(finance.getApprovalAnnexId());
                financeVo.setApprovalAnnexFile(filePD);
            }
            if(StringUtils.isNotNull(finance.getApprovalFinanceId())){
                YzqFile filePD = fileService.getById(finance.getApprovalFinanceId());
                financeVo.setApprovalFinanceFile(filePD);
            }
            ajax.put("Finance",financeVo);
        }
        LastCheck lastCheck = lastCheckService.getById(bean.getLastCheckId());
        //终验
        if(StringUtils.isNotNull(lastCheck)){
            LastCheckVo lastCheckVo = new LastCheckVo();
            BeanUtils.copyProperties(lastCheck,lastCheckVo);
            Date lastAdoptTime = lastCheck.getLastAdoptTime();
            DateFormat dateFormat1 = DateFormat.getDateInstance();
            lastCheckVo.setLastAdoptTime(dateFormat1.format(lastAdoptTime));
            if(StringUtils.isNotNull(lastCheck.getLastAdoptVoucher())){
                YzqFile filePD = fileService.getById(lastCheck.getLastAdoptVoucher());
                lastCheckVo.setLastAdoptVoucherFile(filePD);
            }
            ajax.put("LastCheck",lastCheckVo);
        }
        //合同
        ContractInformation contractInformation = contractInformationService.getById(bean.getContractId());
        if(StringUtils.isNotNull(contractInformation)){
            ContractInformationVo contractInformationVo = new ContractInformationVo();
            BeanUtils.copyProperties(contractInformation,contractInformationVo);
            Date signingTime = contractInformation.getSigningTime();
            DateFormat dateFormat1 = DateFormat.getDateInstance();
            contractInformationVo.setSigningTime(signingTime);
            if(StringUtils.isNotNull(contractInformation.getScannedCopyOfContract())){
                YzqFile filePD = fileService.getById(contractInformation.getScannedCopyOfContract());
                contractInformationVo.setScannedCopyOfContract(filePD);
            }
            if (StringUtils.isNotNull(contractInformation.getTenderAnnouncementFileId())) {
                YzqFile fileTaf = fileService.getById(contractInformation.getTenderAnnouncementFileId());
                contractInformationVo.setTenderAnnouncementFile(fileTaf);
            }
            if (StringUtils.isNotNull(contractInformation.getBidWinningAnnouncementFileId())) {
                YzqFile fileBwaf = fileService.getById(contractInformation.getBidWinningAnnouncementFileId());
                contractInformationVo.setBidWinningAnnouncementFile(fileBwaf);
            }
            ajax.put("ContractInformation",contractInformationVo);
        }
        //里程碑
        List<MilestoneInformationVo> milestoneInformationVoList = milestoneInformationService.selectMilestoneInformationByProId(bean.getProId());
        if(StringUtils.isNotEmpty(milestoneInformationVoList)){
            ajax.put("MilestoneInformation",milestoneInformationVoList);
        }

        //初验
        PreliminaryInformation preliminaryInformation = preliminaryInformationService.getById(bean.getFirstCheckId());
        if(StringUtils.isNotNull(preliminaryInformation)){
            PreliminaryInformationVo preliminaryInformationVo = new PreliminaryInformationVo();
            BeanUtils.copyProperties(preliminaryInformation,preliminaryInformationVo);
            if(StringUtils.isNotNull(preliminaryInformation.getCertificate())){
                YzqFile filePD = fileService.getById(preliminaryInformation.getCertificate());
                preliminaryInformationVo.setCertificateFile(filePD);
            }
            ajax.put("PreliminaryInformation",preliminaryInformationVo);
        }
        //审核进程
        List<ApprovalVo> approvalVoList = approvalService.selectProjectApprovalList(bean.getProId());
        //如果转三方则进行筛选，去除相关审核进程
        if (StringUtils.isNotNull(bean.getTripartiteId())) {
            List<ApprovalVo> collect = approvalVoList.stream().filter(a -> a.getApprovalNode().equals("接受任务")
                    || a.getApprovalNode().equals("在线预审")
                    || a.getApprovalNode().equals("意见汇总")
            ).collect(Collectors.toList());
            approvalVoList.removeAll(collect);
            //大数据局查看名称不同，处理一下
            approvalVoList.forEach(s->{
                if(RoleUtil.getUserRole(Constants.ROLE_TYPE_BIGDATA)){
                    if (s.getApprovalStatus().equals(ProjectStatusEnum.ARRANGE_REVIEW_TO_BE_ACCEPTED.get().getStatus())
                            ||s.getApprovalStatus().equals(ProjectStatusEnum.ARRANGE_REVIEW_MEETING_TO_BE_EXTRACTED.get().getStatus())) {
                        s.setApprovalStatusName("已转派三方");
                    }

                }
                if (s.getApprovalNode().equals("现场论证") && RoleUtil.getUserRole(Constants.ROLE_TYPE_BIGDATA)){
                    if (s.getApprovalStatus().equals(ProjectStatusEnum.ON_SITE_DEMONSTRATION_TO_BE_REVIEWED.get().getStatus())) {
                        s.setApprovalStatus(ProjectStatusEnum.THIRD_PARTY_APPROVAL_TO_BE_REVIEWED.get().getStatus());
                        s.setApprovalNode(ProjectStatusEnum.THIRD_PARTY_APPROVAL_TO_BE_REVIEWED.get().getNode());
                        s.setApprovalStage(ProjectStatusEnum.THIRD_PARTY_APPROVAL_TO_BE_REVIEWED.get().getStage());
                    }else{
                        s.setApprovalStatus(ProjectStatusEnum.THIRD_PARTY_APPROVAL_APPROVED.get().getStatus());
                        s.setApprovalNode(ProjectStatusEnum.THIRD_PARTY_APPROVAL_APPROVED.get().getNode());
                        s.setApprovalStage(ProjectStatusEnum.THIRD_PARTY_APPROVAL_APPROVED.get().getStage());
                    }
                }

            });
            //转三方项目大数据局屏蔽方案修改进程
            if(RoleUtil.getUserRole(Constants.ROLE_TYPE_BIGDATA)){
                List<ApprovalVo> updateApproval = approvalVoList.stream().filter(a -> a.getApprovalNode()
                        .equals(ProjectStatusEnum.SCHEME_DECLARATION_UPDATE_TO_BE_SUBMITTED.get().getNode())).collect(Collectors.toList());
                approvalVoList.removeAll(updateApproval);
            }
            if(!Collections.isEmpty(approvalVoList)){
                ajax.put("Approval",approvalVoList);
                List<ApprovalVo> approvalVos = approvalVoList.stream().filter(s ->
                        !s.getApprovalStatus().equals(ProjectStatusEnum.ACCEPT_NOT_TASK.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.ACCEPT_TASKED.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.ONLINE_PREQUALIFICATION_PENDING_APPROVAL.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.ONLINE_PREQUALIFICATION_APPROVED.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.COMMENTS_SUMMARY_TO_BE_APPROVED.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.OPINION_SUMMARY_APPROVED.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.SUMMARY_AND_RETURN_OF_COMMENTS.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.ON_SITE_DEMONSTRATION_TO_BE_REVIEWED.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.THE_ONSITE_DEMONSTRATION_HAS_BEEN_PASSED.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.ON_SITE_DEMONSTRATION_NEEDS_TO_BE_MODIFIED.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.ON_SITE_DEMONSTRATION_RETURN_RESTATEMENT.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.THIRD_PARTY_APPROVAL_TO_BE_REVIEWED.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.PROGRAM_PREREVIEW_PENDING.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.PROGRAM_PREREVIEW_PASS.get().getStatus())&&
                        !s.getApprovalStatus().equals(ProjectStatusEnum.PROGRAM_PREREVIEW_RETURN_FOR_RETRIAL.get().getStatus())
                ).collect(Collectors.toList());
                projectManagementVo.setApprovalVo(approvalVoList.get(approvalVoList.size()-1));
                //三方论证审核结果为通过，并且三方现场论证为退回重申、通过需修改时，项目单位返回的最新状态为三方现场论证的状态
                List<ApprovalVo> approvalList = approvalService.selectProjectApprovalList(bean.getProId());
                if(approvalList.get(approvalList.size() - 1).getApprovalStatus().equals(ProjectStatusEnum.REVIEW_OF_THIRD_PARTY_APPROVAL_RESULTS_HAS_BEEN_PASSED.get().getStatus())){

                    if(  approvalList.get(approvalList.size() - 2).getApprovalStatus().equals(ProjectStatusEnum.ON_SITE_DEMONSTRATION_NEEDS_TO_BE_MODIFIED.get().getStatus())
                            ||approvalList.get(approvalList.size() - 2).getApprovalStatus().equals(ProjectStatusEnum.ON_SITE_DEMONSTRATION_RETURN_RESTATEMENT.get().getStatus())){
                        ApprovalVo approvalVo = approvalList.get(approvalList.size() - 2);
                        projectManagementVo.setApprovalVo(approvalVo);
                        projectManagementVo.setIsState(approvalVo.getApprovalStatus());
                        projectManagementVo.setNode(approvalVo.getApprovalNode());

                }

                }
            }
        }else {
            if(!Collections.isEmpty(approvalVoList)){
                ajax.put("Approval",approvalVoList);
                projectManagementVo.setApprovalVo(approvalVoList.get(approvalVoList.size()-1));
            }
        }
        ajax.put("data",projectManagementVo);
        ajax.put("reviewType",ReviewTask.REVIEW_TYPE_PROGRAMME);
        // 0 没操作 1 已操作（抽取专家或者转三方）
        ajax.put("type",bean.getReviewTaskId()==null?"0":"1");

        QueryWrapper<Approval> approvalQueryWrapper = new QueryWrapper<>();
        approvalQueryWrapper.eq("project_id",proId)
                .eq("approval_status", Constants.TURN_SENT_TASK)
                .eq("del_flag",Constants.DELETE_STATUS_NORMAL);
        Approval approval = approvalMapper.selectOne(approvalQueryWrapper);
        // 0、没转三方 1、转三方
        ajax.put("isThird",!StringUtils.isNotNull(approval)?"0":"1");
        //返回在线预审审核记录
        List<Approval> approvalList=approvalService.lambdaQuery().eq(Approval::getProjectId,proId)
                .eq(Approval::getApprovalType,Approval.APPROVAL_TYPE_PROJECT_MANAGE)
                .eq(Approval::getApprovalNode,ProjectStatusEnum.ONLINE_PREQUALIFICATION_PENDING_APPROVAL.get().getNode())
                .orderByDesc(Approval::getCreateTime).list();
        if(StringUtils.isNotEmpty(approvalList)){
            ajax.put("online",approvalList.get(0));
        }
        //项目单位增加撤回按钮判断,1 可以撤回 2不能撤回
        if(RoleUtil.getUserRole(Constants.ROLE_TYPE_PROJECT)){

            List<String> list = Arrays.asList(ProjectStatusEnum.STATEMENT_NOT_SUBMITTED.get().getStatus(),
                    ProjectStatusEnum.DECLARATION_SUBMISSION_SUBMITTED.get().getStatus(),
                    ProjectStatusEnum.APPLICATION_REVIEW_TO_BE_REVIEWED.get().getStatus());
            if(list.contains(projectManagementVo.getIsState())){
                ajax.put("retreatType",Constants.DELETE_STATUS_DELETED);
            }else {
                ajax.put("retreatType",Constants.DELETE_STATUS_NORMAL);
            }
        }
         return ajax;
    }

    /**
     * 新增项目管理
     */
    @ApiOperation("新增项目管理")
    @Log(title = "项目管理", businessType = BusinessType.INSERT)
    @PostMapping
    public Long add(@RequestBody ProjectManagementAddDto dto)
    {
        return projectManagementService.insertProjectManagement(dto);
    }

    /**
     * 修改项目管理
     */
//    @PreAuthorize("@ss.hasPermi('web:management:edit')")
    @ApiOperation("修改项目管理")
    @Log(title = "项目管理", businessType = BusinessType.UPDATE)
    @PutMapping("/edit/{proId}")
    public AjaxResult edit(@RequestBody ProjectManagementEditDto dto, @PathVariable Long proId)
    {
        return toAjax(projectManagementService.updateProjectManagement(dto,proId));
    }

    /**
     * 删除项目管理
     */
//    @PreAuthorize("@ss.hasPermi('web:management:remove')")
    @ApiOperation("删除项目管理")
    @Log(title = "项目管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{proId}")
    public AjaxResult remove(@PathVariable Long proId)
    {
        return toAjax(projectManagementService.deleteProjectManagementByProIds(proId));
    }

    /**
     * 获取抽取单位列表
     * @return
     */
    @ApiOperation("获取抽取单位列表")
    @GetMapping("/getCompany")
    public AjaxResult selectCompany(){
        return AjaxResult.success().put("companyList",projectManagementService.getCompany());
    }
    /**
     * 获取项目申报单位列表
     * @return
     */
    @ApiOperation("获取项目申报单位列表")
    @GetMapping("/applyCompany")
    public AjaxResult selectApplyCompany(){
        return AjaxResult.success().put("companyList",projectManagementService.selectApplyCompany());
    }
    /**
     * 统计项目阶段总数
     */
    @ApiOperation("统计项目阶段总数")
    @GetMapping("/projectCount")
    public HashMap<String,String> projectCount()
    {
        return projectManagementService.projectCount();
    }
    /**
     * 大数据局催办生成消息
     */
    @ApiOperation("大数据局催办生成消息")
    @GetMapping("/createMsg/{proId}")
    public AjaxResult createMsg(@PathVariable("proId") Long proId,String info)
    {
        projectManagementService.createMsg(proId,info);
        return AjaxResult.success();
    }
    @ApiOperation("项目单位撤回")
    @GetMapping("/retreat/{proId}")
    public AjaxResult retreat(@PathVariable Long proId)
    {
        return toAjax(projectManagementService.retreat(proId));
    }

    @ApiOperation("现场论证删除文件")
    @Log(title = "现场论证删除文件", businessType = BusinessType.DELETE)
    @DeleteMapping("/deleteFile/{approvalId}")
    public AjaxResult deleteFile(@PathVariable Long approvalId)
    {
        return toAjax(projectManagementService.deleteFile(approvalId));
    }
    @ApiOperation("大数据局-项目退回重申")
    @GetMapping("/returnRepeated")
    public AjaxResult returnRepeated(Long proId,String approvalOpinion)
    {
        return toAjax(projectManagementService.returnRepeated(proId,approvalOpinion));
    }
    @ApiOperation("项目进程文件上传")
    @PostMapping("/uploadPorFile/{approvalId}")
    public AjaxResult uploadPorFile(@PathVariable Long approvalId, @Validated @RequestBody YzqFile file)
    {
        return toAjax(projectManagementService.uploadPorFile(approvalId,file));
    }
    @ApiOperation("查看三方意见汇总的审核意见")
    @GetMapping("/getApprovalOpinion/{proId}")
    public AjaxResult getApprovalOpinion(@PathVariable Long proId)
    {
        return AjaxResult.success().put("data",projectManagementService.getApprovalOpinion(proId));
    }
}
